//
//  DMCCycleImages.h
//  22-AliPlanet_HomeWork
//
//  Created by dllo on 16/8/4.
//  Copyright © 2016年 DM.C. All rights reserved.
//

#import "TuijianTableViewCell.h"
#import "LittleData.h"
#import "TuijianCollecCell.h"

@interface TuijianTableViewCell () <UICollectionViewDataSource, UICollectionViewDelegate>
@property (weak, nonatomic) IBOutlet UICollectionView *collectionView;
@property (weak, nonatomic) IBOutlet UICollectionViewFlowLayout *layout;

@end

@implementation TuijianTableViewCell

- (void)layoutSubviews {
    [super layoutSubviews];
    _collectionView.delegate = self;
    _collectionView.dataSource = self;
    _layout.itemSize = CGSizeMake((self.contentView.frame.size.width - 15) / 2, 80);
    _layout.minimumInteritemSpacing = 5;
    _layout.minimumLineSpacing = 5;
    _layout.sectionInset = UIEdgeInsetsMake(5, 5, 5, 5);
    if (_data) {
        [self.collectionView reloadData];
    }
}

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
    return _data.count;
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
    TuijianCollecCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"tuijian" forIndexPath:indexPath];
    cell.contentView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"bar"]];
    cell.name.text = _data[indexPath.row].name;
    cell.desc.text = _data[indexPath.row].desc;
    return cell;
}
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
    if (indexPath.row == 0) {
        NSLog(@"点击了歌曲推荐的第一个");
    } else if (indexPath.row == 1) {
        NSLog(@"点击了歌曲推荐的第二个");
    }
}
- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
